
<?php
$folder="/data/video/";
$save_url="/data/video/";
if(!empty($_FILES['img']['name'])){
    $picname = $_FILES['img']['name'];
    $picsize = $_FILES['img']['size'];
    if ($picname != "") {
        $type = strstr($picname, '.');
        $rand = rand(1000, 9999);
        $pics = date("YmdHis",time()) . "_".$rand . $type;
        //上传路径
        $targetPath = $_SERVER['DOCUMENT_ROOT'] . $folder;
        $pic_path =  str_replace('//','/',$targetPath) . $pics;
        //mkdir(str_replace('//','/',$targetPath), 0755, true);
        if(!is_dir(str_replace('//','/',$targetPath))){
            mkdir(str_replace('//','/',$targetPath), 0755, true); //创建 目录
        }

        move_uploaded_file($_FILES['img']['tmp_name'], $pic_path);
    }

    
    $size = round($picsize/1024,2);
	$arr = array(
		'name'=>$picname,
		'pic'=>$pics,
		'pic_path'=>$folder.$pics,
		'size'=>$size
	);
	echo json_encode($arr);

}else{
	$arr = null;
	echo json_encode($arr);
}

?>
